!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! the subroutine coded that calculate the intersection
!    point between the treamline and psi-line
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Creator : B. G.
! Date    : 2015-12-06
! Revised :
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Note :
!   I. all angles in rad
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

subroutine INTERSECTION(x_I,y_I,theta_I,psi_I,x2,y2)
implicit none
real*8::x_I,y_I,theta_I,psi_I,x2,y2
real*8::CTemp

! intersection point of two lines list below :
!    1. y=kx+c, slope of tan(theta), pass (x_I, y_I), previous streamline point
!    2. y=kx, slope of tan(psi), pass (0, 0), psi-line

CTemp=y_I-x_I*tan(theta_I)      ! constant c of y=kx+c of the previous streamline point
x2=CTemp/(tan(psi_I)-tan(theta_I))
                                ! x-value of intersection point
y2=x2*tan(psi_I)                ! y-value of intersection point

end subroutine INTERSECTION
